import React, { Component } from 'react'

export default class floor extends Component {
    handleCheckAll = (event) => {
      this.props.CheckAllTodo(event.target.checked)
    }
    handleDeleteAll = () => {
      this.props.ClearAlldone()
    }
    render() {
      const {todos}=this.props
      const donenum=todos.reduce((pre,todo)=>{return pre+(todo.done?1:0)},0)
      
        return (
            <div className="todo-footer">
            <label>
              <input type="checkbox" checked={donenum == todos.length && donenum != 0 ? true : false} onChange={this.handleCheckAll} />
            </label>
            <span>
              <span>已完成{donenum}</span> / 全部{todos.length}
            </span>
            <button className="btn btn-danger" onClick={this.handleDeleteAll}>清除已完成任务</button>
          </div>
        )
    }
}
